Código fuente de 'Agrupa palabras.asp'

<html>
<head>
<title>Agrupa palabras - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>

<body style="font-family: Arial; font-size: 9pt">

<center><b><font face="Arial" size="3">Agrupa palabras</font></b></center><br>

Esta es una función que proporciona la capacidad "wrap" (agrupar palabras).<br>
La función toma una cadena, un número de columna y un valor booleano.<br>
-Si el valor booleano es FALSE entonces la cadena se agrupa hasta el número de columna, siempre que este
sea menor que la longitud de la palabra.<br>
-Si es TRUE, entonces la cadena se agrupa hasta el número de columna dado independientemente 
del final o longitud de la palabra<br><br><b>
Ejemplo: AgrupaPalabras("1 22 333 4444 55555 666666 7777777 88888888 9 1",6,true)<br></b>
<%    response.write "<br>" & AgrupaPalabras("1 22 333 4444 55555 666666 7777777 88888888 9 1",6,true)%>
<br><br><b>
Ejemplo: AgrupaPalabras("1 22 333 4444 55555 666666 7777777 88888888 9 1",6,false)<br></b>
<%    response.write "<br>" & AgrupaPalabras("1 22 333 4444 55555 666666 7777777 88888888 9 1",6,false) %><!--

'**************************************
    ' By: Chip Taylor
    '
    ' Inputs:Function takes a string, a column number, and a forced break boolean. 
    ' If the forced break boolean is FALSE (default) then the string will wrap at the 
    ' nearest end-of-word to the column number.
    ' If TRUE then the string will wrap at the column number regardless of end-of-word
    '
    ' Returns:A string with embedded <br> tags to provide word wraps.
    '
    ' This code is copyrighted and has    ' limited warranties.Please see 
    ' http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=6220&lngWId=4    'for details.    '**************************************
    
   --><%
    
    function AgrupaPalabras(varString,varNumChar,boolBreak)
    ' Function takes a string, a column number, and a forced break boolean. 
    ' If the forced break boolean is FALSE (default) then the string will wrap at the 
    ' nearest end-of-word to the column number.
    ' If TRUE then the string will wrap at the column number regardless of end-of-word
    
    varString=Trim(varString)
    varSetBR = "<BR>"
    result=""
    varString=Replace(varString,chr(13)+chr(10),chr(10))
    
    While varString<>""
    
    if len(varString)<=varNumChar Then
    line=varString
    varString=""
    else
    varTemp1=left(varString,varNumChar)
    iCount=InStrRev(varTemp1," ")
    varInPlace=InStr(varTemp1,"chr(10)")
    if (iCount=0) and Not boolBreak Then iCount=InStr(varString," ")
    if (varInPlace=0) and Not boolBreak Then varInPlace=InStr(varString,chr(10))
    if (varInPlace<ICount) and (varInPlace>0) Then
    finish=j-1
    start=varInPlace+1
    ElseIf iCount=0 Then
    finish=varNumChar
    start=varNumChar+1
    else
    finish=iCount
    start=iCount+1
    End if
    
    line=left(varString,finish)
    varString=ltrim(mid(varString,start))
    End if
    
    'if result="" then result=line else
    result=result&chr(10)&line
    wend
    
    	 if left(result,1) = chr(10) Then
    		result = right(result,(len(result)-1))
    		 End if
    		 
    AgrupaPalabras=Replace(result,chr(10),varSetBR)
    		

    End function
    
    

%>